﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using Mimoza.GUI;
using Mimoza.Common;

namespace Mimoza.Plugins.DisplaySettings
{
    public partial class DisplayPlatformPage : UserControl, Mimoza.GUI.IWizardPage
    {
        #region IWizardPage Members
        private IWizard m_wizard;

        private bool m_IsConfigured = true;

        public void Init(Mimoza.GUI.IWizard wizard)
        {
            m_wizard = wizard;
            m_data = this.Wizard.UserData as DisplayResolution;

            comboBoxPlatfrom.Items.Add(Model.L66_DisplayName);
            comboBoxPlatfrom.Items.Add(Model.C36SX_DisplayName);
            comboBoxPlatfrom.Items.Add(Model.LX_DisplayName);
            comboBoxPlatfrom.Items.Add(Model.VPC_DisplayName);

            if (m_data.Model != ModelEnum.Undefined) comboBoxPlatfrom.SelectedIndex = (int)m_data.Model;

            comboBoxPlatfrom_SelectedIndexChanged(null, null);
            
            this.comboBoxPlatfrom.SelectedIndexChanged += new System.EventHandler(this.comboBoxPlatfrom_SelectedIndexChanged);
        }

        public void EnterPage()
        {
        }

        public bool Try2LeavePage(WizardPageLeavingDirection direction)
        {
            if (direction == WizardPageLeavingDirection.Back)
            {
                return true;
            }

            if (comboBoxPlatfrom.SelectedIndex >= 0)
            {
                m_data.Model = (ModelEnum)comboBoxPlatfrom.SelectedIndex;
                return true;
            }
            return false;
        }

        public Mimoza.GUI.IWizard Wizard
        {
            get
            {
                return m_wizard;
            }
        }

        public string PageName
        {
            get { return Resource.DisplayPlatformPageName; }
        }

        public string PageTitle
        {
            get { return Resource.DisplayPlatformPagetTitle; }
        }

        public bool IsConfigured
        {
            get
            {
                return m_IsConfigured;
            }
            set
            {
                m_IsConfigured = value;
            }
        }

        public event Mimoza.GUI.PageEvent OnPageModified;

        #endregion

        public DisplayPlatformPage()
        {
            InitializeComponent();
        }

        protected void RaiseOnPageModified()
        {
            PageEvent handler = OnPageModified;

            if (handler != null)
            {
                handler(this);
            }
        }

        private void comboBoxPlatfrom_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (comboBoxPlatfrom.SelectedIndex >= 0)
            {
                IsConfigured = true;
            }
            else
            {
                IsConfigured = false;
            }

            if ((int)m_data.Model != comboBoxPlatfrom.SelectedIndex)
            {
                m_data.Model = (ModelEnum)comboBoxPlatfrom.SelectedIndex;

                m_data.Width = 640;
                m_data.Height = 480;
                m_data.Freq = 60;
                m_data.ColorDepth = ColorDepth.Color16Bit;
            }

            if (null != sender)
            {
                this.RaiseOnPageModified();
            }
        }

        static public IEnumerable<DisplayResolution> ResolutionListC36
        {
            get
            {
                yield return new DisplayResolution("640x480x16-60Hz");
                yield return new DisplayResolution("640x480x16-75Hz");
                yield return new DisplayResolution("640x480x16-85Hz");
                yield return new DisplayResolution("800x600x16-60Hz");
                yield return new DisplayResolution("800x600x16-75Hz");
                yield return new DisplayResolution("800x600x16-85Hz");
                yield return new DisplayResolution("1024x768x16-60Hz");
                yield return new DisplayResolution("1024x768x16-75Hz");
                yield return new DisplayResolution("1024x768x16-85Hz");
                yield return new DisplayResolution("1280x1024x16-60Hz");
                yield return new DisplayResolution("1280x1024x16-75Hz");
                yield return new DisplayResolution("1280x1024x16-85Hz");
                yield return new DisplayResolution("640x480x32-60Hz");
                yield return new DisplayResolution("640x480x32-75Hz");
                yield return new DisplayResolution("640x480x32-85Hz");
                yield return new DisplayResolution("800x600x32-60Hz");
                yield return new DisplayResolution("800x600x32-75Hz");
                yield return new DisplayResolution("800x600x32-85Hz");
                yield return new DisplayResolution("1024x768x32-60Hz");
                yield return new DisplayResolution("1024x768x32-75Hz");
                yield return new DisplayResolution("1024x768x32-85Hz");
                yield return new DisplayResolution("1280x1024x32-60Hz");
                yield return new DisplayResolution("1280x720x16-60Hz");
                yield return new DisplayResolution("1280x720x32-60Hz");
                yield return new DisplayResolution("1280x768x16-60Hz");
                yield return new DisplayResolution("1280x768x32-60Hz");
                yield return new DisplayResolution("1280x800x16-60Hz");
                yield return new DisplayResolution("1280x800x32-60Hz");
                yield return new DisplayResolution("1280x960x16-60Hz");
                yield return new DisplayResolution("1280x960x32-60Hz");
                yield return new DisplayResolution("1368x768x16-60Hz");
                yield return new DisplayResolution("1368x768x32-60Hz");
                yield return new DisplayResolution("1400x1050x16-60Hz");
                yield return new DisplayResolution("1400x1050x32-60Hz");
                yield return new DisplayResolution("1440x900x16-60Hz");
                yield return new DisplayResolution("1440x900x32-60Hz");
                yield return new DisplayResolution("1600x1200x16-60Hz");
                yield return new DisplayResolution("1600x1200x32-60Hz");
                yield return new DisplayResolution("1680x1050x16-60Hz");
                yield return new DisplayResolution("1680x1050x32-60Hz");
            }
        }

        static public IEnumerable<DisplayResolution> ResolutionListL66
        {
            get
            {
                yield return new DisplayResolution("640x480x16-60Hz");
                yield return new DisplayResolution("640x480x8-60Hz");
                yield return new DisplayResolution("640x480x32-60Hz");
                yield return new DisplayResolution("800x600x16-60Hz");
                yield return new DisplayResolution("800x600x8-60Hz");
                yield return new DisplayResolution("800x600x32-60Hz");
                yield return new DisplayResolution("1024x768x16-60Hz");
                yield return new DisplayResolution("1024x768x8-60Hz");
                yield return new DisplayResolution("1024x768x32-60Hz");
                yield return new DisplayResolution("1280x1024x8-60Hz");
                yield return new DisplayResolution("1280x1024x16-60Hz");
                yield return new DisplayResolution("1280x1024x32-60Hz");
                yield return new DisplayResolution("1280x768x8-60Hz");
                yield return new DisplayResolution("1280x768x16-60Hz");
                yield return new DisplayResolution("1280x768x32-60Hz");
                yield return new DisplayResolution("1280x960x8-60Hz");
                yield return new DisplayResolution("1280x960x16-60Hz");
                yield return new DisplayResolution("1280x960x32-60Hz");
                yield return new DisplayResolution("640x400x8-85Hz");
                yield return new DisplayResolution("640x400x16-85Hz");
                yield return new DisplayResolution("640x400x32-85Hz");
                yield return new DisplayResolution("800x480x8-60Hz");
                yield return new DisplayResolution("800x480x16-60Hz");
                yield return new DisplayResolution("800x480x32-60Hz");
                yield return new DisplayResolution("848x480x8-60Hz");
                yield return new DisplayResolution("848x480x16-60Hz");
                yield return new DisplayResolution("848X480X32-60Hz");
                yield return new DisplayResolution("720x480x8-60Hz");
                yield return new DisplayResolution("720x480x16-60Hz");
                yield return new DisplayResolution("720x480x32-60Hz");
                yield return new DisplayResolution("720x576x8-60Hz");
                yield return new DisplayResolution("720x576x16-60Hz");
                yield return new DisplayResolution("720x576x32-60Hz");
                yield return new DisplayResolution("640x480x8-75Hz");
                yield return new DisplayResolution("640x480x16-75Hz");
                yield return new DisplayResolution("640x480x32-75Hz");
                yield return new DisplayResolution("800x600x8-75Hz");
                yield return new DisplayResolution("800x600x16-75Hz");
                yield return new DisplayResolution("800x600x32-75Hz");
                yield return new DisplayResolution("1024x768x8-75Hz");
                yield return new DisplayResolution("1024x768x16-75Hz");
                yield return new DisplayResolution("1024x768x32-75Hz");
                yield return new DisplayResolution("1280x1024x8-75Hz");
                yield return new DisplayResolution("1280x1024x16-75Hz");
                yield return new DisplayResolution("1280x1024x32-75Hz");
                yield return new DisplayResolution("640x480x8-85Hz");
                yield return new DisplayResolution("640x480x16-85Hz");
                yield return new DisplayResolution("640x480x32-85Hz");
                yield return new DisplayResolution("800x600x8-85Hz");
                yield return new DisplayResolution("800x600x16-85Hz");
                yield return new DisplayResolution("800x600x32-85Hz");
                yield return new DisplayResolution("1024x768x8-85Hz");
                yield return new DisplayResolution("1024x768x16-85Hz");
                yield return new DisplayResolution("1024x768x32-85Hz");
                yield return new DisplayResolution("1280x1024x8-85Hz");
                yield return new DisplayResolution("1280x1024x16-85Hz");
                yield return new DisplayResolution("1280x1024x32-85Hz");
                yield return new DisplayResolution("320x200x8-85Hz");
                yield return new DisplayResolution("320x200x16-85Hz");
                yield return new DisplayResolution("320x200x32-85Hz");
                yield return new DisplayResolution("320x240x8-85Hz");
                yield return new DisplayResolution("320x240x16-85Hz");
                yield return new DisplayResolution("320x240x32-85Hz");
                yield return new DisplayResolution("400x300x8-85Hz");
                yield return new DisplayResolution("400x300x16-85Hz");
                yield return new DisplayResolution("400x300x32-85Hz");
                yield return new DisplayResolution("512x384x8-85Hz");
                yield return new DisplayResolution("512x384x16-85Hz");
                yield return new DisplayResolution("512x384x32-85Hz");
                yield return new DisplayResolution("480x234x8-60Hz");
                yield return new DisplayResolution("480x234x16-60Hz");
                yield return new DisplayResolution("480x234x32-60Hz");
                yield return new DisplayResolution("1600x1200x8-60Hz");
                yield return new DisplayResolution("1600x1200x16-60Hz");
                yield return new DisplayResolution("1600x1200x32-60Hz");
                yield return new DisplayResolution("1600x1200x8-75Hz");
                yield return new DisplayResolution("1600x1200x16-75Hz");
                yield return new DisplayResolution("1600x1200x8-85Hz");
                yield return new DisplayResolution("1600x1200x16-85Hz");
                yield return new DisplayResolution("1280x720x8-60Hz");
                yield return new DisplayResolution("1280x720x16-60Hz");
                yield return new DisplayResolution("1280x720x32-60Hz");
                yield return new DisplayResolution("1920x1440x8-60Hz");
                yield return new DisplayResolution("1920x1440x16-60Hz");
                yield return new DisplayResolution("1920x1440x32-60Hz");
                yield return new DisplayResolution("1920x1080x8-60Hz");
                yield return new DisplayResolution("1920x1080x16-60Hz");
                yield return new DisplayResolution("1920x1080x32-60Hz");
                yield return new DisplayResolution("1360X768X8-60Hz");
                yield return new DisplayResolution("1360X768X16-60Hz ");
                yield return new DisplayResolution("1360X768X32-60Hz");
                yield return new DisplayResolution("1400x1050x8-60Hz");
                yield return new DisplayResolution("1400x1050X16-60Hz");
                yield return new DisplayResolution("1400x1050X32-60Hz");
                yield return new DisplayResolution("2048x1536x8-60Hz");
                yield return new DisplayResolution("2048x1536x16-60Hz");
                yield return new DisplayResolution("2048x1536x32-60Hz");
                yield return new DisplayResolution("1366x768x8-60Hz");
                yield return new DisplayResolution("1366x768x16-60Hz");
                yield return new DisplayResolution("1366x768x32-60Hz");
                yield return new DisplayResolution("640x480x8-100Hz");
                yield return new DisplayResolution("640x480x16-100Hz");
                yield return new DisplayResolution("640x480x32-100Hz");
                yield return new DisplayResolution("640x480x8-120Hz");
                yield return new DisplayResolution("640x480x16-120Hz");
                yield return new DisplayResolution("640x480x32-120Hz");
                yield return new DisplayResolution("800x600x8-100Hz");
                yield return new DisplayResolution("800x600x16-100Hz");
                yield return new DisplayResolution("800x600x32-100Hz");
                yield return new DisplayResolution("800x600x8-120Hz");
                yield return new DisplayResolution("800x600x16-120Hz");
                yield return new DisplayResolution("800x600x32-120Hz");
                yield return new DisplayResolution("1024x768x8-100Hz");
                yield return new DisplayResolution("1024x768x16-100Hz");
                yield return new DisplayResolution("1024x768x32-100Hz");
                yield return new DisplayResolution("1440x900x8-60Hz");
                yield return new DisplayResolution("1440x900x16-60Hz");
                yield return new DisplayResolution("1440x900x32-60Hz");
                yield return new DisplayResolution("1680x1050x8-60Hz");
                yield return new DisplayResolution("1680x1050x16-60Hz");
                yield return new DisplayResolution("1680x1050x32-60Hz");
                yield return new DisplayResolution("1680x1050x8-75Hz");
                yield return new DisplayResolution("1680x1050x16-75Hz");
                yield return new DisplayResolution("1680x1050x32-75Hz");
                yield return new DisplayResolution("1680x1050x8-85Hz");
                yield return new DisplayResolution("1680x1050x16-85Hz");
                yield return new DisplayResolution("1680x1050x32-85Hz");
                yield return new DisplayResolution("1920x1200x8-60Hz");
                yield return new DisplayResolution("1920x1200x16-60Hz");
                yield return new DisplayResolution("1920x1200x32-60Hz");
                yield return new DisplayResolution("1920x1200x8-75Hz");
                yield return new DisplayResolution("1920x1200x16-75Hz");
                yield return new DisplayResolution("1920x1200x32-75Hz");
            }
        }

        static public IEnumerable<DisplayResolution> ResolutionListLX
        {
            get
            {
                yield return new DisplayResolution("640x480x16-60Hz");
                yield return new DisplayResolution("640x480x8-60Hz");
                yield return new DisplayResolution("640x480x32-60Hz");
                yield return new DisplayResolution("800x600x16-60Hz");
                yield return new DisplayResolution("800x600x8-60Hz");
                yield return new DisplayResolution("800x600x32-60Hz");
                yield return new DisplayResolution("1024x768x16-60Hz");
                yield return new DisplayResolution("1024x768x8-60Hz");
                yield return new DisplayResolution("1024x768x32-60Hz");
                yield return new DisplayResolution("1280x1024x8-60Hz");
                yield return new DisplayResolution("1280x1024x16-60Hz");
                yield return new DisplayResolution("1280x1024x32-60Hz");
                yield return new DisplayResolution("1280x768x8-60Hz");
                yield return new DisplayResolution("1280x768x16-60Hz");
                yield return new DisplayResolution("1280x768x32-60Hz");
                yield return new DisplayResolution("1280x960x8-60Hz");
                yield return new DisplayResolution("1280x960x16-60Hz");
                yield return new DisplayResolution("1280x960x32-60Hz");
                yield return new DisplayResolution("640x400x8-85Hz");
                yield return new DisplayResolution("640x400x16-85Hz");
                yield return new DisplayResolution("640x400x32-85Hz");
                yield return new DisplayResolution("800x480x8-60Hz");
                yield return new DisplayResolution("800x480x16-60Hz");
                yield return new DisplayResolution("800x480x32-60Hz");
                yield return new DisplayResolution("848x480x8-60Hz");
                yield return new DisplayResolution("848x480x16-60Hz");
                yield return new DisplayResolution("848X480X32-60Hz");
                yield return new DisplayResolution("720x480x8-60Hz");
                yield return new DisplayResolution("720x480x16-60Hz");
                yield return new DisplayResolution("720x480x32-60Hz");
                yield return new DisplayResolution("720x576x8-60Hz");
                yield return new DisplayResolution("720x576x16-60Hz");
                yield return new DisplayResolution("720x576x32-60Hz");
                yield return new DisplayResolution("640x480x8-75Hz");
                yield return new DisplayResolution("640x480x16-75Hz");
                yield return new DisplayResolution("640x480x32-75Hz");
                yield return new DisplayResolution("800x600x8-75Hz");
                yield return new DisplayResolution("800x600x16-75Hz");
                yield return new DisplayResolution("800x600x32-75Hz");
                yield return new DisplayResolution("1024x768x8-75Hz");
                yield return new DisplayResolution("1024x768x16-75Hz");
                yield return new DisplayResolution("1024x768x32-75Hz");
                yield return new DisplayResolution("1280x1024x8-75Hz");
                yield return new DisplayResolution("1280x1024x16-75Hz");
                yield return new DisplayResolution("1280x1024x32-75Hz");
                yield return new DisplayResolution("640x480x8-85Hz");
                yield return new DisplayResolution("640x480x16-85Hz");
                yield return new DisplayResolution("640x480x32-85Hz");
                yield return new DisplayResolution("800x600x8-85Hz");
                yield return new DisplayResolution("800x600x16-85Hz");
                yield return new DisplayResolution("800x600x32-85Hz");
                yield return new DisplayResolution("1024x768x8-85Hz");
                yield return new DisplayResolution("1024x768x16-85Hz");
                yield return new DisplayResolution("1024x768x32-85Hz");
                yield return new DisplayResolution("1280x1024x8-85Hz");
                yield return new DisplayResolution("1280x1024x16-85Hz");
                yield return new DisplayResolution("1280x1024x32-85Hz");
                yield return new DisplayResolution("320x200x8-85Hz");
                yield return new DisplayResolution("320x200x16-85Hz");
                yield return new DisplayResolution("320x200x32-85Hz");
                yield return new DisplayResolution("320x240x8-85Hz");
                yield return new DisplayResolution("320x240x16-85Hz");
                yield return new DisplayResolution("320x240x32-85Hz");
                yield return new DisplayResolution("400x300x8-85Hz");
                yield return new DisplayResolution("400x300x16-85Hz");
                yield return new DisplayResolution("400x300x32-85Hz");
                yield return new DisplayResolution("512x384x8-85Hz");
                yield return new DisplayResolution("512x384x16-85Hz");
                yield return new DisplayResolution("512x384x32-85Hz");
                yield return new DisplayResolution("480x234x8-60Hz");
                yield return new DisplayResolution("480x234x16-60Hz");
                yield return new DisplayResolution("480x234x32-60Hz");
                yield return new DisplayResolution("1600x1200x8-60Hz");
                yield return new DisplayResolution("1600x1200x16-60Hz");
                yield return new DisplayResolution("1600x1200x32-60Hz");
                yield return new DisplayResolution("1600x1200x8-75Hz");
                yield return new DisplayResolution("1600x1200x16-75Hz");
                yield return new DisplayResolution("1600x1200x8-85Hz");
                yield return new DisplayResolution("1600x1200x16-85Hz");
                yield return new DisplayResolution("1280x720x8-60Hz");
                yield return new DisplayResolution("1280x720x16-60Hz");
                yield return new DisplayResolution("1280x720x32-60Hz");
                yield return new DisplayResolution("1920x1440x8-60Hz");
                yield return new DisplayResolution("1920x1440x16-60Hz");
                yield return new DisplayResolution("1920x1440x32-60Hz");
                yield return new DisplayResolution("1920x1080x8-60Hz");
                yield return new DisplayResolution("1920x1080x16-60Hz");
                yield return new DisplayResolution("1920x1080x32-60Hz");
                yield return new DisplayResolution("1360X768X8-60Hz");
                yield return new DisplayResolution("1360X768X16-60Hz ");
                yield return new DisplayResolution("1360X768X32-60Hz");
                yield return new DisplayResolution("1400x1050x8-60Hz");
                yield return new DisplayResolution("1400x1050X16-60Hz");
                yield return new DisplayResolution("1400x1050X32-60Hz");
                yield return new DisplayResolution("2048x1536x8-60Hz");
                yield return new DisplayResolution("2048x1536x16-60Hz");
                yield return new DisplayResolution("2048x1536x32-60Hz");
                yield return new DisplayResolution("1366x768x8-60Hz");
                yield return new DisplayResolution("1366x768x16-60Hz");
                yield return new DisplayResolution("1366x768x32-60Hz");
                yield return new DisplayResolution("640x480x8-100Hz");
                yield return new DisplayResolution("640x480x16-100Hz");
                yield return new DisplayResolution("640x480x32-100Hz");
                yield return new DisplayResolution("640x480x8-120Hz");
                yield return new DisplayResolution("640x480x16-120Hz");
                yield return new DisplayResolution("640x480x32-120Hz");
                yield return new DisplayResolution("800x600x8-100Hz");
                yield return new DisplayResolution("800x600x16-100Hz");
                yield return new DisplayResolution("800x600x32-100Hz");
                yield return new DisplayResolution("800x600x8-120Hz");
                yield return new DisplayResolution("800x600x16-120Hz");
                yield return new DisplayResolution("800x600x32-120Hz");
                yield return new DisplayResolution("1024x768x8-100Hz");
                yield return new DisplayResolution("1024x768x16-100Hz");
                yield return new DisplayResolution("1024x768x32-100Hz");
                yield return new DisplayResolution("1440x900x8-60Hz");
                yield return new DisplayResolution("1440x900x16-60Hz");
                yield return new DisplayResolution("1440x900x32-60Hz");
                yield return new DisplayResolution("1680x1050x8-60Hz");
                yield return new DisplayResolution("1680x1050x16-60Hz");
                yield return new DisplayResolution("1680x1050x32-60Hz");
                yield return new DisplayResolution("1680x1050x8-75Hz");
                yield return new DisplayResolution("1680x1050x16-75Hz");
                yield return new DisplayResolution("1680x1050x32-75Hz");
                yield return new DisplayResolution("1680x1050x8-85Hz");
                yield return new DisplayResolution("1680x1050x16-85Hz");
                yield return new DisplayResolution("1680x1050x32-85Hz");
                yield return new DisplayResolution("1920x1200x8-60Hz");
                yield return new DisplayResolution("1920x1200x16-60Hz");
                yield return new DisplayResolution("1920x1200x32-60Hz");
                yield return new DisplayResolution("1920x1200x8-75Hz");
                yield return new DisplayResolution("1920x1200x16-75Hz");
                yield return new DisplayResolution("1920x1200x32-75Hz");
            }
        }

        static public IEnumerable<DisplayResolution> ResolutionListVPC
        {
            get
            {
                yield return new DisplayResolution("640x480x16-60Hz");
                yield return new DisplayResolution("800x600x16-60Hz");
                yield return new DisplayResolution("1024x768x16-60Hz");
                yield return new DisplayResolution("1280x1024x16-60Hz");
            }
        }
        private DisplayResolution m_data;
    }
}
